package cn.tedu._051mvcboot01.controller;

import cn.tedu._051mvcboot01.pojo.Bmi;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class BMIController {
//    @RequestMapping("/bmi")
//    @ResponseBody
//    public String bmi(Double height, Double weight){
//        // soutp + 回车
//        System.out.println("height = " + height + ", weight = " + weight);
//        // 计算
//        Double result = weight / (height * height);
//        // 判断
//        if (result < 18.5){
//            return "你瘦了";
//        }
//        if (result < 24){
//            return "你是正常的";
//        }
//        if (result < 27){
//            return "你是微胖";
//        }
//        return "兄弟，你该减肥了~~";
//    }

    @RequestMapping("/bmi")
    @ResponseBody
    public String bmi(Bmi bmi){
        Double height = bmi.getHeight();
        Double weight = bmi.getWeight();
        Double result = weight / (height * height);
        // 判断
        if (result < 18.5){
            return "你瘦了";
        }
        if (result < 24){
            return "你是正常的";
        }
        if (result < 27){
            return "你是微胖";
        }
        return "兄弟，你该减肥了~~";

    }
}
